<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/core" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/security.tld" prefix="s" %>

<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript">
	function submitQuery(form, orderField, orderType){
		form.orderField.value = orderField;
		form.orderType.value = orderType;
		form.action = "goToFuturePurchasesRealizedList.do";
		if (validSubmit){
			form.submit();
		} else {
			alert('<fmt:message key="warning.message.common.processing"/>');
		}
	}
</script>

<html:form action="/goToFuturePurchasesRealizedList">		
	<html:hidden property="orderField"/>
	<html:hidden property="orderType"/>
	<table align="center" width="570" cellpadding="2" cellspacing="1" border="0" bgcolor="#CCCCC0">
	<tr>		
		<td class="titulocolumna" align="center" width="70">			
				<a href="#>" onclick="return submitQuery(document.FuturePurchasesRealizedForm, 0,'<c:choose><c:when test="${previousOrderField == 0 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
					<bean:message key="label.futurepurchase.query.quantity"/>
					<c:choose>
						<c:when test="${previousOrderField == 0 && previousOrderType == 1}">
							<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
						</c:when>
						<c:when test="${previousOrderField == 0 && previousOrderType == 0}">
							<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
						</c:when>
					</c:choose>
				</a>			
		</td>
		<td class="titulocolumna" align="center" width="50">
			<a href="#>" onclick="return submitQuery(document.FuturePurchasesRealizedForm, 1, '<c:choose><c:when test="${previousOrderField == 1 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.futurepurchase.query.price"/>
				<c:choose>
					<c:when test="${previousOrderField == 1 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 1 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		<td class="titulocolumna" align="center" width="140">
			<a href="#>" onclick="return submitQuery(document.FuturePurchasesRealizedForm, 2, '<c:choose><c:when test="${previousOrderField == 2 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchases.instructions.futures.furchase.period"/>
				<c:choose>
					<c:when test="${previousOrderField == 2 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 2 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>
		</td>
		<td class="titulocolumna" align="center" width="140">
			<a href="#>" onclick="return submitQuery(document.FuturePurchasesRealizedForm, 3, '<c:choose><c:when test="${previousOrderField == 3 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="label.purchases.instructions.futures.furchase.application"/>
				<c:choose>
					<c:when test="${previousOrderField == 3 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 3 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
		<td class="titulocolumna" align="center" width="70">
			<a href="#>" onclick="return submitQuery(document.FuturePurchasesRealizedForm, 4, '<c:choose><c:when test="${previousOrderField == 4 && previousOrderType == 0}">1</c:when><c:otherwise>0</c:otherwise></c:choose>');" class="ligas">
				<bean:message key="message.futurepurchase.reference"/>
				<c:choose>
					<c:when test="${previousOrderField == 4 && previousOrderType == 1}">
						<img alt="<bean:message key="label.common.order.ascending"/>" src="images/arrow_up.gif" border="0"/>
					</c:when>
					<c:when test="${previousOrderField == 4 && previousOrderType == 0}">
						<img alt="<bean:message key="label.common.order.descending"/>" src="images/arrow_down.gif" border="0"/>
					</c:when>
				</c:choose>
			</a>	
		</td>
	</tr>
	<logic:notEmpty name="FUTURE_PURCHASES_REALIZED_LIST">
		<logic:iterate id="row" name="FUTURE_PURCHASES_REALIZED_LIST" indexId="int_i">
			<tr class="<%=((int_i.intValue()%2)==0?"columnadatoPar":"columnadatoNon")%>">																		
				<td align="center"><bean:write name="row" property="quantity"/></td>
				<td align="center"><bean:write name="row" property="unitPrice"  format="###,###,##0.0000"/></td>
				<td align="center"><bean:write name="row" property="accountFuturePeriodName"/></td>
				<td align="center"><bean:write name="row" property="applicationFuturePeriodName"/></td>
				<td align="center"><bean:write name="row" property="reference"/></td>								
			</tr>
		</logic:iterate>
	</logic:notEmpty>
</table>
<br/>
<table border="0" cellspacing="1"  bgcolor="#CCCCC0" width="500">
	<tr>
		<td colspan="4" align="center" class="columnadatoPar">			
			<html:button styleClass="boton" property="backButton" onclick="location.href = 'goToPurchaseDetailReception.do'"><bean:message key="label.common.back"/></html:button> 
		</td>
	</tr>
</table>
<br />
<br />
</html:form>